
import allModel from '@/views/radarSilo/initModel/allModel';

const initModelMethod = {

    initConfModel(siloConf){
        // console.log("????????",siloConf)
        if(!siloConf.siloInitId) return {series:[],legend:[],maxMins:[],realMaxMins:[]};
        var siloInitId = JSON.parse(siloConf.siloInitId);
        var siloParam = JSON.parse(siloConf.siloParam);
        var serieses = [];
        var legends = [];
        var maxMins = [];
        var realMaxMins = [];
        var minZ = undefined;
        var maxZ = undefined;
        maxMins[0] = [];
        maxMins[1] = [];
        maxMins[2] = [];
        maxMins[3] = [];
        realMaxMins[0] = [];
        realMaxMins[1] = [];
        realMaxMins[2] = [];
        realMaxMins[3] = [];

        siloInitId.forEach((item,index) => {
            var object = undefined;
            if(item == '1'){
                object = allModel.circleBarModel(siloParam[index],serieses.length);
            }else if(item == "2"){
                object = allModel.archHorModel(siloParam[index],serieses.length);
            }else if(item == "3"){
                object = allModel.archLonModel(siloParam[index],serieses.length);
            }else if(item == "4"){
                object = allModel.planeModel(siloParam[index],serieses.length);
            }else if(item == "5"){
                object = allModel.planeHorModel(siloParam[index],serieses.length);
            }else if(item == "6"){
                object = allModel.planeLonModel(siloParam[index],serieses.length);
            }

            var series = object.series
            if(minZ == undefined||minZ > object.minZ) minZ = object.minZ
            if(maxZ == undefined||maxZ < object.maxZ) maxZ = object.maxZ
            if(object.maxMin){
                maxMins[0][index] = object.maxMin[0]
                maxMins[1][index] = object.maxMin[1]
                maxMins[2][index] = object.maxMin[2]
                maxMins[3][index] = object.maxMin[3]
            }
            if(object.realMaxMin){
                realMaxMins[0][index] = object.realMaxMin[0]
                realMaxMins[1][index] = object.realMaxMin[1]
                realMaxMins[2][index] = object.realMaxMin[2]
                realMaxMins[3][index] = object.realMaxMin[3]
            }
            serieses.push(series)
            legends.push(series.name)
        });
        maxMins[0] = Math.min(...maxMins[0])
        maxMins[1] = Math.max(...maxMins[1])
        maxMins[2] = Math.min(...maxMins[2])
        maxMins[3] = Math.max(...maxMins[3])
        realMaxMins[0] = Math.min(...realMaxMins[0])
        realMaxMins[1] = Math.max(...realMaxMins[1])
        realMaxMins[2] = Math.min(...realMaxMins[2])
        realMaxMins[3] = Math.max(...realMaxMins[3])
        console.log("???????",minZ)
        return {series:serieses,legend:legends,maxMins:maxMins,realMaxMins:realMaxMins,minZ:minZ,maxZ:maxZ}
    }


}

    
    
export default initModelMethod;